This example demonstrates how to create a simple Broadcast Receiver. It does not require any Android Manifest changes for permissions since the battery does not require it. ----------------------------------------- 1. Add a class called BatteryChecker.java ----------------------------------------- import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.widget.Toast; public class BatteryChecker extends BroadcastReceiver { public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if(action.equals(Intent.ACTION_POWER_CONNECTED)) { // Do something when power connected Toast.makeText(context,"Power Connected",Toast.LENGTH_SHORT).show(); } else if(action.equals(Intent.ACTION_POWER_DISCONNECTED)) { Toast.makeText(context,"Power Disconnected",Toast.LENGTH_SHORT).show(); } } } --------------------------- 2. Update MainActivity.java --------------------------- import androidx.appcompat.app.AppCompatActivity; import android.content.BroadcastReceiver; import android.content.IntentFilter; import android.os.Bundle; public class MainActivity extends AppCompatActivity { BroadcastReceiver receiver; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); configureReceiver(); } private void configureReceiver() { IntentFilter filter = new IntentFilter(); filter.addAction("com.example.myapplication.BatteryChecker"); filter.addAction("android.intent.action.ACTION_POWER_DISCONNECTED"); filter.addAction("android.intent.action.ACTION_POWER_CONNECTED"); receiver = new BatteryChecker(); registerReceiver(receiver, filter); } } ------------------------------------------------------ 3. Compile and Run - No changes to Manifest are needed ------------------------------------------------------